package com.flyduck.common.config;

import com.flyduck.common.util.RedisUtil;
import com.flyduck.common.interceptor.TokenInterceptor;
import com.flyduck.common.util.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: flyduck-platform
 * @description:
 * @author: flyduck
 * @create: 2021-02-06 21:45
 **/
@Configuration
public class WebMvcConfig  implements WebMvcConfigurer {

    @Autowired
    private FlyduckConfig flyDuckConfig;

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private TokenUtil tokenUtil;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenInterceptor(flyDuckConfig, redisUtil, tokenUtil)).addPathPatterns("/**");
    }


}
